package org.jvnet.jaxb2_commons.ppp;

import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JDocComment;
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JMod;
import com.sun.codemodel.JPackage;
import com.sun.tools.xjc.outline.Outline;

/**
 * Creates the Child interface.
 */
public class CreateChildInterface {
    
    static final String parentGetterName = "getParent";

    static final String parentSetterName = "setParent";
    
    protected JPackage mPackage;
    protected Outline mOutline;
    private JDefinedClass mOutput;
    
    /**
     * C'tor
     * @param aOutline
     * @param aPackage
     */
    public CreateChildInterface(Outline aOutline, JPackage aPackage) {
        setOutline(aOutline);
        setPackage(aPackage);
    }

    /**
     * @return
     */
    protected JDefinedClass getOutput() {
        return mOutput;
    }
    
    /**
     * @param aOutput
     */
    protected void setOutput(JDefinedClass aOutput) {
        mOutput = aOutput;
    }

    /**
     * @return
     */
    protected JPackage getPackage() {
        return mPackage;
    }

    /**
     * @param aPackage
     */
    protected void setPackage(JPackage aPackage) {
        mPackage = aPackage;
    }

    /**
     * @return
     */
    protected Outline getOutline() {
        return mOutline;
    }

    /**
     * @param aOutline
     */
    protected void setOutline(Outline aOutline) {
        mOutline = aOutline;
    }
    
    /**
     * @param aClasses
     */
    protected void run() {
        JDefinedClass ifc = mOutline.getClassFactory().createInterface(mPackage, "IHasParent", null);
        setOutput( ifc );
        
        JMethod method = getOutput().method(JMod.PUBLIC, Object.class, parentGetterName);
        JDocComment comment = method.javadoc();
        comment.append("Get the parent object.");
        
        method = getOutput().method(JMod.PUBLIC, void.class, parentSetterName);
        method.param(Object.class, "parent");
        comment = method.javadoc();
        comment.append("Set the parent object.").addParam("parent");
        
    }
}
